package com.tokenmaster.aitrade.init.history_2014;

import java.io.IOException;
import java.text.SimpleDateFormat;

import com.tokenmaster.aitrade.common.ticker.TickerData;
import com.tokenmaster.aitrade.market.virtual.Ticker_History;

public class Run_CreateKLine {

	public static void main(String[] args) {

		Ticker_History ticker_History = Ticker_History.getInstance();
		KLinePoints_Set kLinePoints_Set_5 = new KLinePoints_Set("btc_cny", "5min", 10);
		TickerData tickerData = null;

		while (true) {

			try {
				// 读取行情
				tickerData = ticker_History.getTickerData("btc_cny");
				// 生成 K 线
				kLinePoints_Set_5.newTicker(tickerData);

				// 打印日志
				if (tickerData.getUnixtime() % (60 * 60 * 1000) == 0) {

					SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					String timestr = sformat.format(tickerData.getUnixtime());

					System.out.println(timestr + " : 价格:" + tickerData.getLast());
				}

				Thread.sleep(1);

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}

	}

}
